package com.hongdee.market.grievance.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * Created by Liu XiaoLong
 * Date: 2017/10/27.
 * Remark:
 */
public class TMarketWhineQuery {

    public String list(Map map) {
        String node = (String) map.get("node");
            Map data = (Map) map.get("data");
        SQL sql = new SQL() {{
            SELECT(" * ");
            FROM("t_market_whine ");
            if (!node.equals("all"))
            {
                WHERE("node = #{node}");
            }

            if (!data.get("questionDegree").toString().isEmpty())
            {
                WHERE("degree = #{data.questionDegree}");
            }

            if (!data.get("questionType").toString().isEmpty())
            {
                WHERE("type = #{data.questionType}");
            }

            if (!data.get("progress").toString().isEmpty())
            {
                WHERE("node = #{data.progress}");
            }
        }};
        return sql.toString();
    }
}
